package com.tjbank.cssys.mybatis.impl;

import com.tjbank.cssys.mybatis.IamRoleDao;
import com.tjbank.cssys.mybatis.entity.IamRole;
import com.tjbank.cssys.mybatis.entity.IamRoleKey;
import com.tjbank.cssys.mybatis.mapper.IamRoleMapper;
import com.tjbank.cssys.mybatis.sqlbuilder.IamRoleSqlBuilder;
import java.util.List;
import javax.annotation.Resource;

import org.apache.ibatis.exceptions.TooManyResultsException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

/**
 * IamRoleDaoImpl
 * 
 * @author PG(Auto Generator)
 * @version V2.0
 */
@Service
public class IamRoleDaoImpl implements IamRoleDao {
    @Resource
    private IamRoleMapper iamRoleMapper;

    public IamRoleDaoImpl() {
        super();
    }

    @Override
    public List<IamRole> selectListBySqlBuilderWithBLOBs(IamRoleSqlBuilder iamRoleSqlBuilder) throws RuntimeException {
        return iamRoleMapper.selectBySqlBuilderWithBLOBs(iamRoleSqlBuilder);
    }

    @Override
    public List<IamRole> selectListBySqlBuilder(IamRoleSqlBuilder iamRoleSqlBuilder) throws RuntimeException {
        return iamRoleMapper.selectBySqlBuilder(iamRoleSqlBuilder);
    }

    @Override
    public IamRole selectBySqlBuilderWithBLOBs(IamRoleSqlBuilder iamRoleSqlBuilder) throws RuntimeException {
        List<IamRole> listIamRoles = selectListBySqlBuilderWithBLOBs(iamRoleSqlBuilder);
        if (listIamRoles == null || listIamRoles.isEmpty()) {
            return null;
        } else if (listIamRoles.size() > 1) {
            throw new TooManyResultsException();
        }
        return listIamRoles.get(0);
    }

    @Override
    public IamRole selectBySqlBuilder(IamRoleSqlBuilder iamRoleSqlBuilder) throws RuntimeException {
        List<IamRole> listIamRoles = selectListBySqlBuilder(iamRoleSqlBuilder);
        if (listIamRoles == null || listIamRoles.isEmpty()) {
            return null;
        } else if (listIamRoles.size() > 1) {
            throw new TooManyResultsException();
        }
        return listIamRoles.get(0);
    }

    @Override
    public IamRole selectByPrimaryKey(IamRoleKey iamRoleKey) throws RuntimeException {
        return iamRoleMapper.selectByPrimaryKey(iamRoleKey);
    }

    @Override
    public long countBySqlBuilder(IamRoleSqlBuilder iamRoleSqlBuilder) throws RuntimeException {
        return iamRoleMapper.countBySqlBuilder(iamRoleSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int insert(IamRole iamRole) throws RuntimeException {
        return iamRoleMapper.insert(iamRole);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int insertUseBatch(List<IamRole> listIamRoles) throws RuntimeException {
        return iamRoleMapper.insertUseBatch(listIamRoles);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateBySqlBuilder(IamRole iamRole, IamRoleSqlBuilder iamRoleSqlBuilder) throws RuntimeException {
        iamRoleSqlBuilder.setUpdateObject(iamRole);
        return iamRoleMapper.updateBySqlBuilder(iamRoleSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateBySqlBuilderSelective(IamRole iamRole, IamRoleSqlBuilder iamRoleSqlBuilder) throws RuntimeException {
        iamRoleSqlBuilder.setUpdateObject(iamRole);
        return iamRoleMapper.updateBySqlBuilderSelective(iamRoleSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateByPrimaryKey(IamRole iamRole) throws RuntimeException {
        return iamRoleMapper.updateByPrimaryKey(iamRole);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int updateByPrimaryKeySelective(IamRole iamRole) throws RuntimeException {
        return iamRoleMapper.updateByPrimaryKeySelective(iamRole);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int deleteBySqlBuilder(IamRoleSqlBuilder iamRoleSqlBuilder) throws RuntimeException {
        return iamRoleMapper.deleteBySqlBuilder(iamRoleSqlBuilder);
    }

    @Override
    @Transactional(propagation = Propagation.REQUIRED, rollbackFor = RuntimeException.class)
    public int deleteByPrimaryKey(IamRoleKey iamRoleKey) throws RuntimeException {
        return iamRoleMapper.deleteByPrimaryKey(iamRoleKey);
    }
}